//
//  LeftNavView.swift
//  FirstSwiftProduct
//
//  Created by 知合金服-Mini on 2017/12/15.
//  Copyright © 2017年 范泽华. All rights reserved.
//

import UIKit

class LeftNavView: UIView ,UITableViewDataSource,UITableViewDelegate{
    
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10
    }
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let headView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: 10))
        return headView
    }
    func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat {
        return 10
    }
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let headView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: 10))
        return headView
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: .value1, reuseIdentifier: "cellId")
        cell.imageView?.image = UIImage.init(named: thenameArr[indexPath.section])
        cell.textLabel?.text = cellArr[indexPath.section]
        cell.selectionStyle = .none
        cell.backgroundColor = .clear
        return cell
    }
    func numberOfSections(in tableView: UITableView) -> Int {
        return cellArr.count
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 40
    }
    
    let cellArr = ["我的","你的","他的","到底","是谁的"]
    let thenameArr = ["MoreMyFavorites","MoreMyAlbum","MyCardPackageIcon","MoreExpressionShops","MoreMyBankCard","MoreSetting"]
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setUI()

    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUI()  {
        let table = UITableView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height),style:.plain)
        table.delegate = self
        table.dataSource = self
        self.addSubview(table)
//        table.backgroundColor = .clear
        let imageV = UIImageView.init(frame: table.bounds)
        imageV.image = UIImage.init(named: "aaaa")
        table.backgroundView = imageV
        
        let head = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: SCRENN_HEIGHT/4))
//        head.backgroundColor = .green
        table.tableHeaderView = head
        let headImageView = UIImageView.init()
        headImageView.image = UIImage.init(named: "father")
        
        
        table.separatorStyle = .none
        
    }
    
    
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
